define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'category/index',
        add_url: 'category/add',
        edit_url: 'category/edit',
        delete_url: 'category/delete',
        export_url: 'category/export',
        modify_url: 'category/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [
                        {
                                text: '添加',
                                url: init.add_url,
                                method: 'open',
                                auth: 'add',
                                class: 'layui-btn layui-btn-normal layui-btn-sm',
                                icon: 'fa fa-plus ',
                            }
                        ],
                    ],
                cols: [[
                    {field: 'sort', title: '排序',edit:true, search: false}, 
                    {field: 'name', title: '分类名称'},
                    {field: 'cur_status', title: '状态', width: 85, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch},
                    {field: 'created_at', title: '添加时间', search: false},
                    {width: 250, title: '操作', templet: ea.table.tool},

                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});